package com.jiunuan.live.core.server.common;

import io.netty.channel.ChannelHandlerContext;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author: JiuNuan
 * @CreateTime: 2024-08-13 19:59
 * @Description: channel绑定，map
 */

public class ChannelHandlerContextCache {
    /**
      *  当前的im服务启动时，对外暴露的ip和端口（nacos上注册的）
      */
    public static String SERVER_IP_ADDRESS = "";
    private static Map<Long, ChannelHandlerContext> channelHandlerContextMap = new HashMap<>();
    public static String getServerIpAddress() {
        return SERVER_IP_ADDRESS;
    }
    public static void setServerIpAddress(String serverIpAddress) {
        SERVER_IP_ADDRESS = serverIpAddress;
    }
    public static ChannelHandlerContext get(Long userId){
        return channelHandlerContextMap.get(userId);
    }
    public static void put(Long userId, ChannelHandlerContext ctx){
        channelHandlerContextMap.put(userId, ctx);
    }

    public static void remove(Long userId){
        channelHandlerContextMap.remove(userId);
    }
}
